#
# Copyright 2024 Kumo.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# below are examples, after initialization, modify it to your own.
###########################################################################
###kmcmake_example
#[[
kmcmake_cc_library(
        NAMESPACE ${PROJECT_NAME}
        NAME foo
        SOURCES
        foo.cc
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PLINKS
        ${KMCMAKE_DEPS_LINK}
        PUBLIC
)

kmcmake_cc_interface(
        NAMESPACE ${PROJECT_NAME}
        NAME api
        HEADERS
        api.h
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        PUBLIC
)

kmcmake_cc_binary(
        NAMESPACE ${PROJECT_NAME}
        NAME shared_main
        SOURCES
        main.cc
        CXXOPTS
        ${KMCMAKE_CXX_OPTIONS}
        DEPS
        ${PROJECT_NAME}::foo
        LINKS
        ${KMCMAKE_DEPS_LINK}
        ${PROJECT_NAME}::foo
        PUBLIC
)
]]

###kmcmake_example

include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR})


add_cython_target(executor CXX)
add_library(executor MODULE ${executor} python/error.cpp python/GILAwareManualExecutor.cpp python/ProactorExecutor.cpp)
#add_dependencies(executor cxx_lib)
target_link_libraries(executor  ${KMCMAKE_DEPS_LINK})

python_extension_module(executor)



add_cython_target(fiber_manager CXX)
add_library(fiber_manager MODULE ${fiber_manager} python/error.cpp python/fibers.cpp)
#add_dependencies(fiber_manager cxx_lib)
target_link_libraries(fiber_manager  ${KMCMAKE_DEPS_LINK})
python_extension_module(fiber_manager)

install(TARGETS fiber_manager LIBRARY DESTINATION .)

add_cython_target(iobuf CXX)
add_library(iobuf MODULE ${iobuf} python/error.cpp python/iobuf_ext.cpp)
#add_dependencies(iobuf cxx_lib)
target_link_libraries(iobuf  ${KMCMAKE_DEPS_LINK})
python_extension_module(iobuf)

install(TARGETS iobuf LIBRARY DESTINATION .)